/*
 * geliFrame.h
 *
 *  Created on: 2011-10-7
 *  Author    : gelif(admin@gelif.net)
 */

#ifndef GELIFRAME_H_
#define GELIFRAME_H_

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/frame.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/ipcbase.h>
#include <windows.h>
#include <GL/glu.h> /* GLU extention library */

////Header Include Start
#include <wx/stattext.h>
//#include <wx/listbox.h>
#include <wx/button.h>
#include <wx/panel.h>
////Header Include End

#include <vector>
#ifndef GAME_H
#include "game.h"
#endif
class TCPClient;
class TCPServer;
#ifndef GELIFTCP_H
#include "geliftcp.h"
#endif
class GelifGLCanvas;
#ifndef GELIFGLCANVAS_H
#include "gelifglcanvas.h"
#endif
#ifndef HOSTJOIN_H
#include "hostjoin.h"
#endif
////Dialog Style Start
#undef GELIFRAME_STYLE
#define GELIFRAME_STYLE wxCAPTION | wxSYSTEM_MENU | wxMINIMIZE_BOX | wxCLOSE_BOX
////Dialog Style End


class GeliFrame: public wxFrame
{
private:
DECLARE_EVENT_TABLE()

public:
    GelifGLCanvas *boardGLCanvas;
    TCPClient *client;
    TCPServer *server;
    HostJoinDialog *hostjoinDialog;

public:
    GeliFrame(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("geliFrame"), const wxPoint& pos =
            wxDefaultPosition, const wxSize& size = wxDefaultSize);
    virtual ~GeliFrame();

    // Various functions
    void shutdownServer();

public:
    wxTimer *timerDraw;

    wxStaticText *wxStaticText1;
    wxButton *buttonDisconnect;
    //wxListBox *listServer;
    wxButton *buttonHost;
    wxButton *buttonJoin;
    wxPanel *panelBoard;
    wxPanel *panelBackground;

    void buttonHostClick(wxCommandEvent& event);
    void buttonJoinClick(wxCommandEvent& event);
    void buttonDisconnectClick(wxCommandEvent& event);
    void enableConnect();
    void disableConnect();
    void updateEverybody(); // sends all the board coordinates to everyone

    void clearServerList();

    void timerDrawTimer(wxTimerEvent& event);

    void poke(const wxString &item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
    Game* game;
private:
    enum
    {
        ID_WXSTATICTEXT5 = 1078,
        ID_TIMERDRAW = 1048,
        ID_BUTTONDISCONNECT = 1021,
        //ID_LISTSERVER = 1020,
        ID_BUTTONHOST = 1014,
        ID_BUTTONJOIN = 1013,
        ID_PANELBOARD = 1002,
        ID_PANELBACKGROUND = 1001,
        ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
    };


private:
    void onClose(wxCloseEvent& event);
    void createGUIControls();
};

#endif /* GELIFRAME_H_ */
